package com.yxcz.model;
// Generated 2016-1-15 15:47:26 by Hibernate Tools 4.3.1.Final

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;

/**
 * Role generated by hbm2java
 */
@Entity
@Table(name = "role", catalog = "yxczoa")
public class Role implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8011257051100620761L;
	private Integer id;
	private String name;
	private Integer sequence;
	private Boolean status;
	private String remark;
	private Set<User> users;
	private Set<Menu> menus=new HashSet<>();

	public Role() {
	}

	public Role(String name, Integer sequence, Boolean status, String remark) {
		this.name = name;
		this.sequence = sequence;
		this.status = status;
		this.remark = remark;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)

	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "sequence")
	public Integer getSequence() {
		return this.sequence;
	}

	public void setSequence(Integer sequence) {
		this.sequence = sequence;
	}

	@Column(name = "status")
	public Boolean getStatus() {
		return this.status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}

	@Column(name = "remark", length = 65535)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@ManyToMany(cascade={CascadeType.PERSIST})
	@JsonBackReference  
	@JoinTable(name = "role_user", joinColumns = @JoinColumn(name = "role_id") , inverseJoinColumns = @JoinColumn(name = "user_id") )
	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	@ManyToMany(cascade={CascadeType.PERSIST})
	@JsonManagedReference 
	@JoinTable(name = "role_menu", joinColumns = @JoinColumn(name = "role_id") , inverseJoinColumns = @JoinColumn(name = "menu_id") )
	public Set<Menu> getMenus() {
		return menus;
	}

	
	public void setMenus(Set<Menu> menus) {
		this.menus = menus;
	}
	
	

}
